package cn.finder.estimote;

import java.util.UUID;

import com.estimote.sdk.Beacon;
import com.estimote.sdk.MacAddress;
import com.estimote.sdk.Utils;

public class FinderBeacon extends Beacon{

	
	public FinderBeacon(UUID proximityUUID, MacAddress macAddress, int major,
			int minor, int measuredPower, int rssi) {
		super(proximityUUID, macAddress, major, minor, measuredPower, rssi);
	}
	
	/***
	 * 获取设备距离
	 * @return
	 */
	public double getDistance(){
		return Utils.computeAccuracy(this);
	}

	
	 public boolean equals(Object o) {
	        if(this == o) {
	            return true;
	        } else if(o != null && this.getClass() == o.getClass()) {
	            Beacon beacon = (Beacon)o;
	            return getMajor() != beacon.getMajor()?false:(getMinor() != beacon.getMinor()?false:getProximityUUID().equals(beacon.getProximityUUID()));
	        } else {
	            return false;
	        }
	    }

    public int hashCode() {
        int result = getProximityUUID().hashCode();
        result = 31 * result + getMajor();
        result = 31 * result + getMinor();
        return result;
    }
	
	
	public static enum BeaconSourceStatus{
		
		NEW_FINDER, //新发现
		LEAVE,     //断开，离开的，超越距离的
		UPDATED    // 之前已经发现 距离更新的
	}
	
}
